import type { IConfig } from './entity';
import type { IPageParams } from '@/types/table'
import request from '@/api/request'

export function getConfigs(params: IPageParams) {
  return request({
    url: '/sys/config/list',
    method: 'get',
    params,
    loading: true
  })
}

export function getConfigById(id: number) {
  return request({
    url: `/sys/config/info/${id}`,
    method: 'get'
  })
}

export function deleteConfigById(id: number) {
  return request({
    url: '/sys/config/delete',
    method: 'post',
    data: [id],
    loading: true
  })
}

export function saveConfig(data: IConfig) {
  return request({
    url: `/sys/config/${data.id ? 'update' : 'save'}`,
    method: 'post',
    data,
    loading: true
  })
}